#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------
# -- This's login thread
# -- 
# ****************************
# Author: lmay.Zhou
# Blog: www.lmaye.com
# Date: 2017年8月21日18:32:56
# ----------------------------------------------------------

from PyQt5 import QtCore
from PyQt5.QtCore import pyqtSignal
from files.logs import Logger
from files.service import UserService


class LoginThread(QtCore.QThread):
    # 通过类成员对象定义信号对象
    _signal = pyqtSignal(object);
    _log = Logger.log();

    def __init__(self, parent=None):
        super(LoginThread, self).__init__();

    def __del__(self):
        self.wait();

    def run(self):
        # 处理Service业务逻辑
        us = UserService();
        # 模拟睡眠
        # self.sleep(5);
        loginRequest = us.login(self.userName, self.password);
        self._log.info("This's login thread ：%s", loginRequest);
        self._signal.emit(loginRequest);

    # def callBack(self, msg):
    #     # 信号焕发，我是通过我封装类的回调来发起的
    #     self._signal.emit(msg);

    @property
    def userName(self):
        return self._userName;

    @userName.setter
    def userName(self, value):
        self._userName = value;

    @property
    def password(self):
        return self._password;

    @password.setter
    def password(self, value):
        self._password = value;
